//
// Created by Administrator on 2022/1/17.
// 模型导入相关
//

#ifndef OPENGLLEARN_2_IMPORTEDMODEL_H
#define OPENGLLEARN_2_IMPORTEDMODEL_H

#include "Utils.h"
#include "glm/glm.hpp"
#include "glm/gtc/type_ptr.hpp"
#include <vector>

class ImportedModel
{
public:
    explicit ImportedModel(const char* filePath);
    int GetNumVertices() const { return numVertices; }
    std::vector<glm::vec3> GetVertices() { return vertices; }
    std::vector<glm::vec2> GetUVs() { return uvs; }
    std::vector<glm::vec3> GetNormals() { return normals; }

private:
    int numVertices;
    std::vector<glm::vec3> vertices;
    std::vector<glm::vec2> uvs;
    std::vector<glm::vec3> normals;
};

class ModelImporter
{
public:
    ModelImporter() = default;
    void ParseOBJ(const char* filePath);
    int GetNumVertices() { return vertices.size() / 3; }
    std::vector<float> GetVertices() { return vertices; }
    std::vector<float> GetUVs() { return uvs; }
    std::vector<float> GetNormals() { return normals; };

private:
    std::vector<float> vs;
    std::vector<float> vts;
    std::vector<float> vns;
    std::vector<float> vertices;
    std::vector<float> uvs;
    std::vector<float> normals;
};

#endif //OPENGLLEARN_2_IMPORTEDMODEL_H
